/*
 * @Author: ziqi jhzq12345678
 * @Date: 2024-09-24 09:02:43
 * @LastEditors: wangdazhuang
 * @LastEditTime: 2024-11-30 10:53:17
 * @FilePath: /pornhub_app/lib/src/components/marqueer/marqueer_list.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:marqueer/marqueer.dart';

import '../../assets/styles.dart';
import '../../model/deduct/deduct_models.dart';

class MarqueerList extends StatelessWidget {
  final Widget widgets;
  final Widget? sepreate;
  final MarqueerDirection? direction;
  final double? speed;
  // models时用到
  final TextStyle? textStyle;

  const MarqueerList(this.widgets,
      {super.key, this.sepreate, this.direction, this.speed})
      : textStyle = null;

  const MarqueerList.single(Widget widget,
      {super.key, this.sepreate, this.direction, this.speed})
      : widgets = widget,
        textStyle = null;

  MarqueerList.deducts(
    DeductTypeModel models, {
    super.key,
    this.sepreate,
    this.direction,
    this.speed,
    this.textStyle,
  }) : widgets = Text(
          models.content,
          style: textStyle ?? TextStyle(fontSize: Styles.fontSize.s),
        );

  @override
  Widget build(BuildContext context) {
    return Marqueer.builder(
      pps: speed ?? 15,
      direction: direction ?? MarqueerDirection.rtl,
      restartAfterInteractionDuration: const Duration(seconds: 3),
      itemBuilder: (_, index) {
        return widgets;
      },
      separatorBuilder: (_, index) {
        return sepreate ?? SizedBox(width: 64.w);
      },
    );
  }
}
